﻿﻿<script type="text/javascript">
var activity_utils = {
    extend : function(obj1, obj2) {
        for(var key in obj2) {
            if(obj2[key]){
                obj1[key] = obj2[key];
            }
        }
    },
    getQueryParamString: function(params) {
        var queryStringArr = [];
        for(var key in params) {
            queryStringArr.push(key + '=' + params[key]);
        }
        return queryStringArr.join('&');
    }
}
function getActivityData(relativePathPrefix,activityid,callback){
	var url = relativePathPrefix+ "activity/select_activity.do?activityid="+activityid;
	var ajax = new AJAX_OBJ(url, callback);
	ajax.requestData();
}
 
function getActivityViewData(relativePathPrefix,f_av_id,f_av_type,activityid,f_av_info,callback){
	var url = relativePathPrefix+ "activity/select_activityView.do?activityid="+activityid+"&f_av_id="+f_av_id+"&f_av_type="+f_av_type+"&f_av_info="+f_av_info;
	var ajax = new AJAX_OBJ(url,callback);
	ajax.requestData();
}

/* 获取用户抽奖次数  */
function getActivityUserCount(relativePathPrefix,serverid,activityid,f_aca_time,f_aca_model,callback,sign){
	var url = relativePathPrefix+ "activity/get_activityUserCount.do?activityid="+activityid+"&serverid="+serverid+"&f_aca_time="+f_aca_time+"&f_aca_model="+f_aca_model+"&sign="+sign;
	var ajax = new AJAX_OBJ(url, callback);
	ajax.requestData();
}

/* 获取中奖用户数  */
function getAwardActivityUserCount(relativePathPrefix,activityid,f_aca_time,f_aca_model,callback){
	var url = relativePathPrefix+ "activity/get_awardActivityUserCount.do?activityid="+activityid+"&f_aca_time="+f_aca_time+"&f_aca_model="+f_aca_model;
	var ajax = new AJAX_OBJ(url, callback);
	ajax.requestData();
}

/* 获取该用户中间次数  */
function getAwardActivityUser(relativePathPrefix,pamarJson,callback){
	var url = relativePathPrefix+ "activity/get_awardActivityUserCount.do?serverid="+pamarJson.serverid+"&activityid="+pamarJson.activityid+"&f_aca_time="
			+pamarJson.f_aca_time+"&f_aca_model="+pamarJson.f_aca_model+'&sign='+pamarJson.sign;
	var ajax = new AJAX_OBJ(url, callback);
	ajax.requestData();
}

/* 获取中奖用户数列表 sign代表 all mine */
function getAwardActivityUserList(relativePathPrefix,serverid,activityid,f_aca_time,f_aca_model,sign,callback){
	var url = relativePathPrefix+ "activity/get_awardActivityUserList.do?serverid="+serverid+"&activityid="+activityid+"&f_aca_time="+f_aca_time+"&f_aca_model="+f_aca_model+"&sign="+sign;
	var ajax = new AJAX_OBJ(url, callback);
	ajax.requestData();
}


/* url  接口地址
	serverid 用户iTV账号
	activityid 活动ID，由用户俱乐部提供给活动方
	awardlevel  奖项，默认为0
	vt 平台版本编号
	source--action 请求方名称 作为IP筛选
	phone 用户手机号
	
	private String url;// 接口地址
	private String action;// String Y 16 请求方名称 作为IP筛选
	private String userid;// String Y 24 用户iTV账号
	private int activityid;// Int Y 4 活动ID，由用户俱乐部提供给活动方
	private int awardlevel;// Int Y 4 奖项，默认为0
	private int vt;// Int Y 平台版本编号
	private String ts;// String Y 14 请求时间戳yyyyMMddHHmmss
	private String digest;// String Y 32
							// 摘要，HEX(MD5(action+userid+activityid+awardlevel+vt+ts))
	private String phone;// String N 11 用户手机号
	*/
function getLotteryResult(relativePathPrefix,url,serverid,source,phone,activityid,awardlevel,vt,callback){
	var url = relativePathPrefix+ "activity/get_lotteryResult.do?url="+url+"&userid="+serverid+"&action="+source+"&phone="+phone+"&activityid="+activityid+"&awardlevel="+awardlevel+"&vt="+vt;
	var ajax = new AJAX_OBJ(url,callback);
	ajax.requestData();
}
/* 
 * 
 *查询奖品对象 
 * 
 */
function selectActivityAward(relativePathPrefix,activityid,info,grade,awardid,callback){
	var url = relativePathPrefix+ "activity/select_activityAward.do?activityid="+activityid+"&info="+info+"&grade="+grade+"&awardid="+awardid;
	var ajax = new AJAX_OBJ(url,callback);
	ajax.requestData();
}

/* 插入用户抽奖记录，答题活动模板也是调用这个接口  */

//insertUserLotteryResult(String actmodel,String acttime,String serverid,String activityid,String phone,String grade,String detail){
function insertUserLotteryResult(relativePathPrefix,actmodel,acttime,serverid,activityid,phone,grade,detail,callback){
	var url = relativePathPrefix+ "activity/insert_userLotteryResult.do?actmodel="+actmodel+"&acttime="+acttime+"&serverid="+serverid+"&activityid="+activityid+"&phone="+phone+"&grade="+grade+"&detail="+detail;
	var ajax = new AJAX_OBJ(url,callback);
	ajax.requestData();
}

function insertUserLotteryResultV2(relativePathPrefix,paramJson,callback){
	var url = relativePathPrefix+ "activity/insert_userLotteryResultv2.do?actmodel="+paramJson.actmodel+"&f_aca_time="+paramJson.f_aca_time
			+"&f_aqu_serverid="+paramJson.f_aqu_serverid+"&f_aqu_activityid="+paramJson.f_aqu_activityid+"&f_aqu_phone="+paramJson.f_aqu_phone
			+"&grade="+paramJson.grade+"&f_aqu_info="+paramJson.f_aqu_info+'&f_aqu_obligate1='+paramJson.f_aqu_obligate1
			+'&f_aqu_obligate2='+paramJson.f_aqu_obligate2+"&f_aqu_count="+paramJson.f_aqu_count;
	var ajax = new AJAX_OBJ(url,callback);
	ajax.requestData();
}

function selectQuestionTitle(relativePathPrefix,activityid,numberId,callback){
	var url = relativePathPrefix+ "activity/select_questionTitle.do?numberId="+numberId+"&activityid="+activityid;
	var ajax = new AJAX_OBJ(url,callback);
	ajax.requestData();
}
function selectQuestionCount(relativePathPrefix,activityid,callback){
	var url = relativePathPrefix+ "activity/select_questionCount.do?activityid="+activityid;
	var ajax = new AJAX_OBJ(url,callback);
	ajax.requestData();
}
function selectAllQuestionAnswerList(relativePathPrefix,activityid,callback){
	var url = relativePathPrefix+ "activity/selectAllQuestionAnswerByActivityid.do?activityid="+activityid;
	var ajax = new AJAX_OBJ(url,callback);
	ajax.requestData();
}

/* counts,info这两个字段是答题模板特有的 */
function updateActivityUserData(relativePathPrefix,actmodel,insertId,phone,counts,info,callback){
	var url = relativePathPrefix+ "activity/update_activityUserData.do?actmodel="+actmodel+"&insertId="+insertId+"&phone="+phone+"&counts="+counts+"&info="+info;
	var ajax = new AJAX_OBJ(url,callback);
	ajax.requestData();
}
function sendIdouMethod(relativePathPrefix,serverid,activityid,f_aoa_idou,flag,phone,callback){
	var url = relativePathPrefix+ "activity/sendIdouMethod.do?serverid="+serverid+"&activityid="+activityid+"&f_aoa_idou="+f_aoa_idou+"&flag="+flag+"&phone="+phone;
	var ajax = new AJAX_OBJ(url,callback);
	ajax.requestData();
}

function getDrawPhone(relativePathPrefix,serverid,sign,callback){
	var url = relativePathPrefix+ "activity/getDrawPhone.do?serverid="+serverid+'&sign='+sign;
	var ajax = new AJAX_OBJ(url,callback);
	ajax.requestData();
}
/* 查询有首页弹出框的在线活动 */
function selectOnlineActivity(relativePathPrefix,serverid,resolution,callback){
	var url =relativePathPrefix+ "activity/selectOnlineActivity.do?serverid="+serverid+'&resolution='+resolution;
	var ajax = new AJAX_OBJ(url,callback);
	ajax.requestData();
}

/* 用来添加联合活动中用户的订购数据 */
 
function insertActUserOrder(relativePathPrefix,f_ub_info,f_ub_productid,f_ub_type,f_ub_fee,f_ub_source,callback){
	var url =relativePathPrefix+ 'activity/insertActUserOrder.do?f_ub_info='+f_ub_info+'&f_ub_productid='+f_ub_productid+'&f_ub_type='+f_ub_type+'&f_ub_fee='+f_ub_fee+'&f_ub_source='+f_ub_source;
	var ajax = new AJAX_OBJ(url,callback);
	ajax.requestData();
}
/**
 * 投票方法
 */
function voteActivity(relativePathPrefix,f_avu_contentid,f_avu_votenum,f_avu_activityid,f_avu_source,f_avu_type,f_avu_memo,callback){
	var url =relativePathPrefix+ 'activity/vote.do?f_avu_contentid='+f_avu_contentid+'&f_avu_votenum='+f_avu_votenum+'&f_avu_activityid='+f_avu_activityid+'&f_avu_source='+f_avu_source+'&f_avu_type='+f_avu_type+"&f_avu_memo="+f_avu_memo;
	var ajax = new AJAX_OBJ(url,callback);
	ajax.requestData();
	
}	
/**
 * 查询用户票数 
 */
function selectUserVotes(relativePathPrefix,f_avu_activityid,callback){
	var url =relativePathPrefix+ 'activity/selectVote.do?f_avu_activityid='+f_avu_activityid;
	var ajax = new AJAX_OBJ(url,callback);
	ajax.requestData();
	
}	
/**
 * 根据分类id查询队伍信息与票数
 */
function selectVoteGroupByCatalogId(relativePathPrefix,f_catalog_id,callback){
	var url =relativePathPrefix+ 'activity/selectVoteGroupByCatalogId.do?f_catalog_id='+f_catalog_id;
	var ajax = new AJAX_OBJ(url,callback);
	ajax.requestData();
}

/**
 * 查询用户的中奖信息
 */
function selectUseraward(relativePathPrefix, paramJson, callback) {
	var url = relativePathPrefix + 'activity/selectUseraward.do?f_au_serverid=' + paramJson.f_au_serverId + '&f_au_grade='
			+ paramJson.f_au_grade + '&f_au_cdate=' + paramJson.f_au_cdate+'&f_au_activityid='+paramJson.f_au_activityid;
	var ajax = new AJAX_OBJ(url, callback);
	ajax.requestData();
}

/* 获取活动次数 */
function getGameCount(relativePathPrefix,serverId,activityId,callback){
    var url = relativePathPrefix+"selectGameCount.do?serverId="+serverId+"&activityId="+activityId;
    var ajax = new AJAX_OBJ(url, callback);
    ajax.requestData();
}

/* 插入活动记录成果 */
function insertGameInfo(relativePathPrefix,serverId,activityId,gameName,count,callback){
    var url = relativePathPrefix+"insertGameList.do?serverId="+serverId+"&activityId="+activityId+"&gameName="+gameName+"&count="+count;
    var ajax = new AJAX_OBJ(url, callback);
    ajax.requestData();
}
/* 查询一个活动下的问题列表 */
function selectQuestions(relativePathPrefix,paramJson,callback){
    var url = relativePathPrefix+"activity/selectQuestions.do?f_csqc_activityid="+paramJson.f_csqc_activityid;
    var ajax = new AJAX_OBJ(url, callback);
    ajax.requestData();
}
/* 查询一个活动下的问题和答案列表 */
function selectAllQuestionAnswerByActivityid(relativePathPrefix,activityid,callback){
	var url = relativePathPrefix+ "activity/selectAllQuestionAnswerByActivityid.do?activityid="+activityid;
	var ajax = new AJAX_OBJ(url, callback);
	ajax.requestData();
}

/* 插入调查问卷结果，参数为json字符串*/
function insertAnswerUser(relativePathPrefix,jsonStr,callback){
	var url = relativePathPrefix+ "activity/insertAnswerUser.do?jsonStr="+jsonStr;
	var ajax = new AJAX_OBJ(url, callback);
	ajax.requestData();
}

/* base64 解码  */
function b64_to_utf8( str ) {
    return decodeURIComponent(escape(window.atob( str )));
}
/* base64 加密  */
function utf8_to_b64( str ) {
    return window.btoa(unescape(encodeURIComponent( str )));
}
/* 判断手机号  */
function isPoneAvailable(phone) {
    var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
    if (!myreg.test(phone)) {
        return false;
    } else {
        return true;
    }
}

function insertOrUpdateIdou(relativePathPrefix,f_ai_serverid,f_ai_activityid,callback){
	var url = relativePathPrefix+ "activity/insertOrUpdateIdou.do?f_ai_serverid="+f_ai_serverid+"&f_ai_activityid="+f_ai_activityid;
	var ajax = new AJAX_OBJ(url, callback);
	ajax.requestData();
}

function selectIdouByIdActId(relativePathPrefix,f_ai_serverid,f_ai_activityid,f_ai_date,callback){
	var url = relativePathPrefix+ "activity/selectIdouByIdActId.do?f_ai_serverid="+f_ai_serverid+"&f_ai_activityid="+f_ai_activityid+"&f_ai_date="+f_ai_date;
	var ajax = new AJAX_OBJ(url, callback);
	ajax.requestData();
}

function insertIdouInfo(relativePathPrefix,f_ai_serverid,f_ai_activityid,callback){
	var url = relativePathPrefix+ "activity/insertIdouInfo.do?f_ai_serverid="+f_ai_serverid+"&f_ai_activityid="+f_ai_activityid;
	var ajax = new AJAX_OBJ(url, callback);
	ajax.requestData();
}

function selectSignInCount(relativePathPrefix,f_ai_serverid,f_ai_activityid,callback){
	var url = relativePathPrefix+ "activity/selectSignInCount.do?f_ai_serverid="+f_ai_serverid+"&f_ai_activityid="+f_ai_activityid;
	var ajax = new AJAX_OBJ(url, callback);
	ajax.requestData();
}

function selectSignInCountOne(relativePathPrefix,f_ai_serverid,f_ai_activityid,callback){
	var url = relativePathPrefix+ "activity/selectSignInCountOne.do?f_ai_serverid="+f_ai_serverid+"&f_ai_activityid="+f_ai_activityid;
	var ajax = new AJAX_OBJ(url, callback);
	ajax.requestData();
}

function insertUserActivityInfo(relativePathPrefix,paramJson,callback){
	var url = relativePathPrefix + "userActivityInfo/insertUserActivityInfo.do?f_uai_serverid="+paramJson.f_uai_serverid+"&f_uai_activityid="+paramJson.f_uai_activityid+"&f_uai_username="+paramJson.f_uai_username+"&f_uai_picId="+paramJson.f_uai_picId
				+"&f_uai_grade="+paramJson.f_uai_grade+"&f_uai_medal="+paramJson.f_uai_medal+"&f_uai_competite="+paramJson.f_uai_competite+"&f_uai_delayed="+paramJson.f_uai_delayed+"&f_uai_regrets="+paramJson.f_uai_regrets+"&f_uai_replace="+paramJson.f_uai_replace
				+"&f_uai_obligate1="+paramJson.f_uai_obligate1+"&f_uai_obligate2="+paramJson.f_uai_obligate2;
	var ajax = new AJAX_OBJ(url,callback);
	ajax.requestData();
}

function updateUserActivityInfo(relativePathPrefix,paramJson,callback){
	var url = relativePathPrefix + "userActivityInfo/updateUserActivityInfo.do?f_uai_serverid="+paramJson.f_uai_serverid+"&f_uai_activityid="+paramJson.f_uai_activityid+"&f_uai_username="+paramJson.f_uai_username+"&f_uai_picId="+paramJson.f_uai_picId
				+"&f_uai_grade="+paramJson.f_uai_grade+"&f_uai_medal="+paramJson.f_uai_medal+"&f_uai_competite="+paramJson.f_uai_competite+"&f_uai_delayed="+paramJson.f_uai_delayed+"&f_uai_regrets="+paramJson.f_uai_regrets+"&f_uai_replace="+paramJson.f_uai_replace
				+"&f_uai_obligate1="+paramJson.f_uai_obligate1+"&f_uai_obligate2="+paramJson.f_uai_obligate2;
	var ajax = new AJAX_OBJ(url,callback);
	ajax.requestData();
}

function selectUserActivityInfo(relativePathPrefix,paramJson,callback){
	var url = relativePathPrefix + "userActivityInfo/selectUserActivityInfo.do?f_uai_serverid="+paramJson.f_uai_serverid+"&f_uai_activityid="+paramJson.f_uai_activityid;
	var ajax = new AJAX_OBJ(url,callback);
	ajax.requestData();
}

function updateUserActivityInfoCompetite(relativePathPrefix,paramJson,callback){
	var url = relativePathPrefix + "userActivityInfo/updateUserActivityInfoCompetite.do?f_uai_serverid="+paramJson.f_uai_serverid+"&f_uai_activityid="+paramJson.f_uai_activityid;
	var ajax = new AJAX_OBJ(url,callback);
	ajax.requestData();
}

function selectContentList(relativePathPrefix,paramJson,callback){
	var url = relativePathPrefix + "userActivityInfo/selectContentList.do?catalogIds="+paramJson.catalogIds+"&f_cc_onlinedate="+paramJson.f_cc_onlinedate;
	var ajax = new AJAX_OBJ(url,callback);
	ajax.requestData();
}

/* f_csqc_viewindex  1,答题；2,语音；3,跳舞 */
function selectQuestionAnswerList(relativePathPrefix,f_cc_id,activityid,f_csqc_viewindex,callback){
	var url = relativePathPrefix+ "activity/selectQuestionAnswerList.do?f_csqc_activityid="+activityid+"&f_csqc_contentid="+f_cc_id+"&f_csqc_viewindex="+f_csqc_viewindex;
	var ajax = new AJAX_OBJ(url,callback);
	ajax.requestData();
}

function insertPersonalizedActivityVo(relativePathPrefix,paramJson,callback){
    var url = relativePathPrefix+ "personalactivity/insertPersonalizedActivityVo.do";
    var queryparams = activity_utils.getQueryParamString(paramJson);
    url += '?'+ queryparams;
    var ajax = new AJAX_OBJ(url,callback);
    ajax.requestData();
}

function selectPersonalizedActivityVo(relativePathPrefix,paramJson,callback){
    var url = relativePathPrefix+ "personalactivity/selectPersonalizedActivityVo.do";
    var queryparams = activity_utils.getQueryParamString(paramJson);
    url += '?'+ queryparams;
    var ajax = new AJAX_OBJ(url,callback);
    ajax.requestData();
}

function selectPersonalizedActivityStats(relativePathPrefix,paramJson,callback){
    var url = relativePathPrefix+ "personalactivity/selectPersonalizedActivityStats.do";
    var queryparams = activity_utils.getQueryParamString(paramJson);
    url += '?'+ queryparams;
    var ajax = new AJAX_OBJ(url,callback);
    ajax.requestData();
}

function selectUserBill(relativePathPrefix,paramJson,callback){
    var url = relativePathPrefix+"service/selectUserBill.do";
    var queryparams = activity_utils.getQueryParamString(paramJson);
    url += '?'+ queryparams;
    var ajax = new AJAX_OBJ(url,callback);
    ajax.requestData();
}

</script>